24 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
25 #define For(i, a, b) for (int i=(a); i<(b); ++i)
26 #define D(x) cout << #x " is " << x << endl
28 typedef pair
<int, int> point
;
30 const int MAXN
= 10000;
38 for (int i
= 0; i
< MAXR
; ++i
) {
39 for (int j
= 0; j
< MAXW
; ++j
) {
40 sum
[i
][j
] = mat
[i
][j
];
41 if (i
> 0) sum
[i
][j
] += sum
[i
-1][j
];
42 if (j
> 0) sum
[i
][j
] += sum
[i
][j
-1];
43 if (i
> 0 and j
> 0) sum
[i
][j
] -= sum
[i
-1][j
-1];
48 int rectangle(int r1
, int c1
, int r2
, int c2
) {
49 int ans
= sum
[r2
][c2
];
50 if (r1
> 0) ans
-= sum
[r1
-1][c2
];
51 if (c1
> 0) ans
-= sum
[r2
][c1
-1];
52 if (r1
> 0 and c1
> 0) ans
+= sum
[r1
-1][c1
-1];
56 void solve(int height
, int width
) {
58 for (int i
= 0; i
+ height
< MAXR
; ++i
) {
59 for (int j
= 0; j
+ width
< MAXW
; ++j
) {
60 int option
= rectangle(i
, j
, i
+ height
, j
+ width
);
61 if (option
> ans
) ans
= option
;
69 while (scanf("%d %d", &N
, &R
) == 2) {
70 if (N
== 0 and R
== 0) break;
71 memset(mat
, 0, sizeof mat
);
73 for (int i
= 0; i
< N
; ++i
) {
75 scanf("%d %d", &distance
, &angle
);
76 mat
[distance
][angle
]++;
77 mat
[distance
][angle
+ 360]++;
85 scanf("%d %d", &distance
, &angle
);
86 solve(distance
- 1, angle
);